import redis
import pymysql
import config
import csv


def readfile(filepath,encoding='GBK'):
    with open(filepath,encoding=encoding) as file:
        return file.read()

#
# conn = pymysql.connect(**config.mysql_option)
# cursor = conn.cursor()

r = redis.StrictRedis(host='localhost', port= 6379)

infos = str(r.get("med_flow"),'GBK')
print(info)

infos = infos.split(";")

with open("data.csv","w") as data:
    writer = csv.writer(data)
    for i in infos:
        writer.writerow(i.split("|||"))


content = readfile("data.csv").encode('utf8')
with open("data.csv",'wb') as data:
    data.write(content)



